<html lang="en">
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <!--<script type="text/javascript" src="../../static/js/login/jquery.min.js"></script>-->
    <script src="../../../../static/struct/layuimini/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script src="../../../../static/js/generaljs/watermarkbycanvas.js" charset="UTF-8"></script>
    <link rel="stylesheet" href="../../../../static/css/generalcss/layuitablecheckboxfix.css">
    <script src="../../../../static/struct/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../../../static/struct/layuimini/lib/layui-v2.5.5/css/layui.css " media="all">

</head>
<body onload="addWaterMarker()">
<!--
<p>Hello, <shiro:principal/>, how are you today?</p>
<p><shiro:user>guest</shiro:user></p>
<span th:text="${session.usercode}">人员工号</span>
-->
<br/>
<div class="layui-form">
    <form class="layui-form" action="#" method="post" id="userform">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">用户ID</label>
                <div class="layui-input-inline">
                    <input type="text" name="cuserid" readonly placeholder="系统自动生成" autocomplete="off" class="layui-input"  >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">用户工号</label>
                <div class="layui-input-inline">
                    <input type="text" name="userCode" id='usercode' lay-verify="required" autocomplete="off" class="layui-input" onblur="setmail()">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">用户名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="userName" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">电子邮件</label>
                <div class="layui-input-inline">
                    <input type="text" id="mail" name="email" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否锁定</label>
                <div class="layui-input-inline">

                    <select name="islocked" lay-verify="" lay-filter="islocked" id="islocked">
                        <option value="N" selected>否</option>
                        <option value="Y">是</option>
                    </select>

                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button"  class="layui-btn" lay-submit="" lay-filter="demo1" onclick="adduser()">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>
</div>

</body>

<script>
    let form;
    layui.use(['form'], function () {
            form = layui.form;
        let layer = layui.layer;
    });

    function setmail() {
        $('#mail').val($('#usercode').val() + '@hongfa.cn');
    }

    function adduser() {
        /*layui.use(['layer', 'form'], function () {
            let form = layui.form;
            let layer = layui.layer;*/
            //form.verify();
            let formjson = $("#userform").serialize();
            //console.log(JSON.stringify(formjson));
            $.post("/action/adduser",formjson,function (resultjson) {
                if (resultjson.code == '200'){
                    parent.layer.closeAll();
                    //location.reload();
                    parent.layer.msg("保存成功");
                }else {
                    console.log(resultjson.msg);
                    layer.msg("保存失败" + resultjson.msg);
                }
            });
        //});

    }
</script>

</html>